package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.member.dos.MemberCoupon;
import com.enation.app.javashop.service.member.MemberCouponManager;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;


/**
 * 会员相关api
 *
 * @author zh
 * @version v7.0
 * @date 18/7/30 下午8:10
 * @since v7.0
 */
@Api(description = "会员优惠券相关api")
@RestController
@RequestMapping("/client/members")
@Validated
@ApiIgnore
public class MemberCouponClientController {

    @Autowired
    private MemberCouponManager memberCouponManager;

    @GetMapping("/coupons")
    public List<MemberCoupon> listByCheckout(@RequestParam("seller_ids") Long[] sellerIds, @RequestParam("member_id") Long memberId) {
        return memberCouponManager.listByCheckout(sellerIds, memberId);
    }

    @GetMapping("/coupons/{mc_id}")
    public MemberCoupon getModel(@RequestParam("member_id") Long memberId, @PathVariable("mc_id") Long mcId) {
        return memberCouponManager.getModel(memberId, mcId);
    }

    @PostMapping("/coupons/update-seller-name")
    public void updateSellerName(@RequestParam("seller_id") Long sellerId,@RequestParam("seller_name")String sellerName) {
        memberCouponManager.updateSellerName(sellerId,sellerName);
    }


}
